//
//  ViewController.swift
//  UILableDemo
//
//  Created by itshizhan on 2020/9/26.
//  Copyright © 2020 itshizhan. All rights reserved.
//

import UIKit

class ViewController: UIViewController {

	override func viewDidLoad() {
		super.viewDidLoad()
		//initView1()
		initView1()
	}
	
	// 最基本的布局方式
	fileprivate func initView1() {
		let lable = UILabel(frame: CGRect(x: 0, y: 0, width: 200, height: 200))
	
		lable.text = "Hello Swift，Hello Swift，Hello Swift，Hello Swift"
		lable.backgroundColor = UIColor.gray
		lable.textColor = UIColor.blue
		lable.font = UIFont.systemFont(ofSize:20)
		lable.textAlignment = NSTextAlignment.left
		lable.numberOfLines = 0
		view.addSubview(lable)
	}
	
	// 居中布局
	fileprivate func initView2() {
		let lable = UILabel()
		lable.text = "Hello Swift，Hello Swift，Hello Swift，Hello Swift"
		lable.frame.size = CGSize(width: 200, height: 200)
		lable.center = view.center
		lable.backgroundColor = UIColor.gray
		lable.textColor = UIColor.blue
		lable.font = UIFont.systemFont(ofSize:20)
		lable.textAlignment = NSTextAlignment.left
		lable.numberOfLines = 0
		view.addSubview(lable)
	}
	
	
	/** 其它用法：
	// 设置阴影
	label.shadowColor=UIColor.gray
	label.shadowOffset=CGSize(width:1.5,height:1.5)
	
	//文字过长时的省略方式
	label.lineBreakMode= .byTruncatingTail//隐藏尾部并显示省略号
	label.lineBreakMode= .byTruncatingMiddle//隐藏中间部分并显示省略号
	label.lineBreakMode= .byTruncatingHead//隐藏头部并显示省略号
	label.lineBreakMode= .byClipping//截去多余部分也不显示省略号
	
	//设置和获取tag
	lable.tag = 101
	let lableTag = view.viewWithTag(101) as! UILabel
	
	// 设置字体
	//public /*not inherited*/ init?(name fontName: String, size fontSize: CGFloat)
	label.font=UIFont(name:"Arial",size:20)
	
	*/
	
	
	
	
	
}

